﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace RiskMan.DataClass.Models.RM
{
    public class InstrumentsAvaragePriceOpen : INotifyPropertyChanged
    {
        #region private

        private string _instrument;
        private double _priceOpen;
        private int _quantity;
        private double _cumSum;

        private int _prevQuantity;

        #endregion

            

        #region public


        /// <summary>
        /// предыдущее значение контрактов на расчет
        /// </summary>
        public int PrevQuantity
        {
            get { return _prevQuantity; }
            set
            {
                if (_prevQuantity != value)
                {
                    _prevQuantity = value;
                    RaisePropertyChanged("PrevQuantity");
                }
            }
        }

        /// <summary>
        /// Накопленная сумма,обнуляется при новом изменении маржи
        /// </summary>
        public double CumSum
        {
            get { return _cumSum; }
            set
            {
                if (_cumSum != value)
                {
                    _cumSum = value;
                    RaisePropertyChanged("CumSum");
                }
            }
        }

        /// <summary>
        /// Инструмент
        /// </summary>
        public string Instrument
        {
            get { return _instrument; }
            set
            {
                if (_instrument != value)
                {
                    _instrument = value;
                    RaisePropertyChanged("Instrument");
                }
            }
        }

        /// <summary>
        /// Цена инструмента
        /// </summary>
        public double PriceOpen
        {
            get { return _priceOpen; }
            set
            {
                if (_priceOpen != value)
                {
                    _priceOpen = value;
                    RaisePropertyChanged("PriceOpen");
                }
            }
        }

        /// <summary>
        /// Количество контрактов
        /// </summary>
        public int Quantity
        {
            get { return _quantity; }
            set
            {
                if (_quantity != value)
                {
                    _quantity = value;
                    RaisePropertyChanged("Quantity");
                }
            }
        }

        #endregion

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;


        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
